<?php 
// 正侧表达式
include "../function/function.php";


// 执行正侧表达式的匹配，输出1则成功，0则失败
$a="/www\.baidu\.com/";
$b="fhdkfkjg3535454 www.baidu.com fatq54625tqgv";
$a1=preg_match($a, $b);
echo $a1;

// 一些特殊字符和元字符作为原子,统统使用"\"转义字符进行转义即可。
$c="/\./";
$c1="www.baidu.com";
echo preg_match($c, $c1);

// preg_match_all()函数方法
$d="/xuebin(si)/";
$d1="xuebinsi5 1234567 xuebinsijiaoyuwang .ppppxuebinsi si green bluesi red";
$d2=[];
preg_match_all($d, $d1, $d2);
// 因为得出的结果是多维数组，所以用var_dump
var_dump($d2);


// 通过一个正则表达式分隔字符串
$e = "www.baidu.com";
$e1 = "/\./";
$e2 = preg_split($e1, $e);
var_dump($e2);


// 执行一个正则表达式的搜索和替换

$f="www.baidu.comdu comdu";
$f1="/du/";
$f2="xxxxxx";
$f3=preg_replace($f1, $f2, $f,2);
var_dump($f3);



$str = "学并思官网www.xuebingsiwang.com学并思论坛  http://bbs.xuebingsiwang.com我在学并思的网名叫xuebingsi";
$preg = "/(xuebingsi)(wa)n(g)/";

$newStr= preg_replace($preg,"<span  style='color:red'>$2</span>wang",$str);
// 上面的$n是表示第n个小括号
var_dump($newStr) ;


exit();

// 匹配手机号码
$phone = "15834576834";
$preg = "/^1(3[0-9]|5[56789]|8[9812])[0-9]{8}$/";
$c = preg_match($preg, $phone);
var_dump($c);



// 匹配邮箱
$mail = "3We@sdff.com.cn";
$preg = "/^[a-z0-9][a-z0-9_]*@[a-z0-9][a-z0-9-]*(\.[a-z]{2,})+$/i";
$c = preg_match($preg, $mail);
var_dump($c);


$name="aaaZZQATT";
$preg1="/^[A-z]{4,7}$/";
$pp=preg_match($preg1, $name);
var_dump($pp);






$str=file_get_contents("http://www.lagou.com/jobs/list_%E5%89%8D%E7%AB%AF%E5%BC%80%E5%8F%91?px=default&gj=3%E5%B9%B4%E5%8F%8A%E4%BB%A5%E4%B8%8B&city=%E5%B9%BF%E5%B7%9E#filterBox");

file_put_contents("./test.html",$str);



$preg = "/<a href=\"\/\/(.+)\" target=\"_blank\" class=\"position_link fl wordCut/";

// <a href="//www.lagou.com/jobs/1635190.html" target="_blank" class="position_link fl wordCut" data-index="0" data-lg-tj-id="rx00" data-lg-tj-no="0001" data-lg-tj-cid="1635190">java开发工程师（广州）<span>[广州]</span></a>

// $preg = "/JAVA(.+)工程师/";

$data=[];
$c = preg_match_all($preg, $str ,$data);

// var_dump($c);

var_dump($data);



















 ?>